<?php
declare(strict_types=1);

namespace app\admin\controller;

use app\admin\service\LocationService;
use app\AdminController;

class Location extends AdminController
{
    /**
     * 获取城市
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getCity()
    {
        $city = LocationService::getCity(intval($this->request->param('pid')));
        return adminResponseJson($city, 1);
    }

    /**
     * 获取地区
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getArea()
    {
        $area = LocationService::getArea(intval($this->request->param('pid')));
        return adminResponseJson($area, 1);
    }
}